package com.zlp.mall.portal.config;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.zlp.mall.common.api.RespCode;
import com.zlp.mall.common.exception.CustomException;
import com.zlp.mall.common.util.MethodUtil;
import com.zlp.mall.portal.modules.ums.model.Member;
import com.zlp.mall.portal.modules.ums.service.MemberService;
import com.zlp.mall.portal.security.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/** 
 * 存放 Session 配置
 * @date: 2021/10/15 13:49
 */
@Component
@Slf4j(topic = "SessionMap")
public class SessionMap {

    @Resource
    protected MemberService memberService;


    public static ConcurrentHashMap<String, Object> sessionMap;

    static {
        sessionMap = new ConcurrentHashMap<>();
    }

    private SessionMap(){}

    public static void setValue(String key,Object obj){
        sessionMap.put(key,obj);
    }

    public static Object getValue(String key){
        Object obj = sessionMap.get(key);
        return obj;
    }

    public Member getSessionUser(){

        Member member = SecurityUtils.getUser();
        return member;
    }

}
